package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicQkItemDAO;
import com.cssy.yd.logic.entity.LogicQkItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-16
 */
public class LogicQkItemDAOImpl extends SqlMapClientDaoSupport implements LogicQkItemDAO {

    /**
     * 插入数据
     * @param logicQkItemDO
     * @return 插入数据的主键
     */
    public String insertLogicQkItemDO(LogicQkItemDO logicQkItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicQkItem.insert", logicQkItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicQkItemDO
     * @return 查出的记录数
     */
    public Integer countLogicQkItemDOByExample(LogicQkItemDO logicQkItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicQkItem.countByDOExample", logicQkItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicQkItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicQkItemDO(LogicQkItemDO logicQkItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicQkItem.update", logicQkItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicQkItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicQkItemDO> findListByExample(LogicQkItemDO logicQkItemDO) throws DataAccessException {
        List<LogicQkItemDO> list = getSqlMapClientTemplate().queryForList("LogicQkItem.findListByDO", logicQkItemDO);
        return list;
    }

    /**
     * 根据主键获取logicQkItemDO
     * @param id
     * @return logicQkItemDO
     */
    public LogicQkItemDO findLogicQkItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicQkItemDO logicQkItemDO = (LogicQkItemDO) getSqlMapClientTemplate().queryForObject("LogicQkItem.findByPrimaryKey", id);
        return logicQkItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicQkItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicQkItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicQkItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicQkItemDO> list = getSqlMapClientTemplate().queryForList("LogicQkItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicQkItem_ex.count", scs);
  	      return count;
  	}
}